#!/bin/sh

. /etc/init.d/functions

VIP=192.168.100.10

start () {
ifconfig tunl0 ${VIP} broadcast $VIP netmask 255.255.255.255 up
route add -host ${VIP[$i]} dev tunl0

echo 1 >/proc/sys/net/ipv4/conf/tunl0/arp_ignore 
echo 2 >/proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 0 >/proc/sys/net/ipv4/conf/tunl0/rp_filter
echo 1 >/proc/sys/net/ipv4/conf/tunl0/forwarding
echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore 
echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce
}
stop () {
ifconfig tunl0 ${VIP} broadcast $VIP netmask 255.255.255.255 down
route del -host ${VIP[$i]} dev tunl0

echo 0 >/proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 0 >/proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 0 >/proc/sys/net/ipv4/conf/tunl0/rp_filter
echo 0 >/proc/sys/net/ipv4/conf/tunl0/forwarding
echo 0 >/proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 >/proc/sys/net/ipv4/conf/all/arp_announce
}

case "$1" in
        start)
        start
        action "RS is starting" /bin/true
        ;;
        stop)
        stop
        action "RS is stoping" /bin/true
        ;;
        *)
        echo "Usage:$0 [start|stop]"
esac
